package com.itheima03.day16test;

import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;
import java.util.Scanner;

/**
 * @author 刘全
 * @date 2021/8/9
 */
public class SendTest3 {
    public static void main(String[] args) throws IOException {
        /**
         * 3. 使用UDP协议完成数据传输
         *     发送端发送，接收端接收
         */
        DatagramSocket ds = new DatagramSocket();

        Scanner sc = new Scanner(System.in);
        byte[] bytes = sc.nextLine().getBytes();
        int port = 10086;
        InetAddress address = InetAddress.getByName("127.0.0.1");
        DatagramPacket dp = new DatagramPacket(bytes, bytes.length, address, port);

        ds.send(dp);

        ds.close();
    }
}
